﻿/**	kanon.h
 *	----	Create Time Stamp	--2008-01-06 23:23:44--
 *------------------------------------------------------------------------------
 *	Mean	:
 *	Author	:Nick Shallery	(nicknide@gmail.com)
 *	Version	:1.0.9.21	(2009-10-11 15:34:05)
 *------------------------------------------------------------------------------
**/	/*YOU HAVE ALL LEFT WITH THIS CODE WHILE YOU KEEP COMMENT IN EVERY COPY.*/

#if			!defined(__LOLIX__PRETTY__KANON__NICK__K_IN_G__)
#define		__LOLIX__PRETTY__KANON__NICK__K_IN_G__
//==============================================================================
//--------------------------------------------------------------------------

#if			!defined(__LOLIX__LOLIX_TYPE__K_IN_G__)
	#include	"../lolix_type.h"
#endif	//	!defined(__LOLIX__LOLIX_TYPE__K_IN_G__)
#if			!defined(__LOLIX__LOLI_X_MACRO__K_IN_G__)
	#include	"../lolix_macro.h"
#endif	//	!defined(__LOLIX__LOLI_X_MACRO__K_IN_G__)

namespace lolix{
	namespace loli{
		class	file;
	}
	namespace sola{
		class	dancer;
	}
}


namespace lolix{namespace pretty{class	kanon;}}

class LOLIX_NO_VTABLE lolix::pretty::kanon
	: public lolix::itf
{
public:
	LOLIX_DEFINE_FACTORY((0xebe10c64, 0x97664419, 0x9ab7f46b, 0x8ad42786), (kanon**, size_type** sty, size_type grp_size));
	LOLIX_DECLARE_ITF(lolix::pretty::kanon, lolix::itf, (0x3a141d85, 0x34b940d3, 0x8d4d3613, 0xd0d4d50e));
	enum	ENUM_KENON_SPT	//	support
	{
		KANON_SPT_EAX_VER		,
		KANON_SPT_BUFFER_FMT	,

		_VER	= 0				,
	};

	enum	ENUM_KENON_STYLE
	{
		KENON_STYLE_MAX_PLAYER_SIZE	,	//	(0, ...)
		KENON_STYLE_SUPPORT_EAX		,	//	(0x0, ...)	0: no need , 0x0100 => EAX 1.0, xyzw => EAX xy.zw
		KENON_SOUND_SPEED			,	//	343400 mm => 343.4 m
		KENON_DISTANCE_MODEL		,	//	
		KENON_STYLE_CNT				,
		KENON_STYLE_VER = 0			,
	};

	enum	ENUM_KBUFFER_TYPE
	{
		KBUFFER_TYPE_WAVE	= 0,
		KBUFFER_TYPE_OGG	= 1,

		KBUFFER_TYPE_VER	= 0,
	};

	enum	ENUM_KANON_FMT
	{
		KANON_FMT_MONO	,
		KANON_FMT_STEREO,
		KANON_FMT_VER	= 0,
	};


	struct	ksource_info
	{
		enum { _s_ver = 0 };
		enum
		{	FMT_MONO
		,	FMT_STEREO
		,	FMT_REAR
		,	FMT_QUAD
		,	FMT_51CHN
		,	FMT_61CHN
		,	FMT_71CHN
		,	FMT_81CHN
		,	_e_ver = 0
		};

		lx_u32		bytes	:  8;	//	sizeof ksource_info
		lx_u32		freq	: 24;	//	max : 16Mb ?
		lx_u32		size	: 32;	//	max : 4G;
		//
		lx_u32		fmt		:  8;
		lx_u32		bits	:  8;	//	max : 128bits ??
		lx_u32		rsv00	: 16;
		lx_u32		rsv01	: 32;
		//
		//lx_u32		_rsv01	: 64;
		//
		//void*		kbuffer		;
	};


	class	LOLIX_NO_VTABLE	ksource
		: public itf
	{
	public:
		LOLIX_DEFINE_FACTORY((0xa227ec37, 0x88254f60, 0xb8f54d52, 0x77fd269a), (ksource** out_ptr));
		LOLIX_DECLARE_ITF(lolix::pretty::kanon::ksource, lolix::itf, (0x946c1e18, 0xe7b44934, 0x9d5deaa1, 0xbe7aa745));
		__LOLIX_INTERFACE(ktype		, LOLIX_RETNV,	(LOLIX_ITF_ID* out_tp_id)const);
		__LOLIX_INTERFACE(cove		, LOLIX_RETNV,	(const LOLIX_ITF_ID*));
		__LOLIX_INTERFACE(kinf		, LOLIX_RETNV,	(ksource_info* out_ptr, const void** kdata)const);
		__LOLIX_INTERFACE(spt_kbf	, LOLIX_RETNV,	(LOLIX_ITF_ID* out_id, size_type* io_size)const);
	};

	//	通过 kanon::query_itf 来取得， LOLIX_ITF_ID const* in_id 为缓冲区类型ID : kbuf_type_XXXX
	class	LOLIX_NO_VTABLE	kbuffer
		: public ksource
	{
	public:
		LOLIX_DECLARE_ITF(lolix::pretty::kanon::kbuffer, lolix::pretty::kanon::ksource, (0xb23ea054, 0xe9b3446f, 0xa0d0d87d, 0xb0b09f53));
		__LOLIX_INTERFACE(load		, LOLIX_RETNV,	(loli::file*));
		__LOLIX_INTERFACE(save		, LOLIX_RETNV,	(loli::file*)const);
	};

	class	LOLIX_NO_VTABLE	kstream
		: public ksource
	{
	public:
		LOLIX_DECLARE_ITF(lolix::pretty::kanon::kstream, lolix::pretty::kanon::ksource, (0x290e3e52, 0x2e8d49f8, 0x9d4e87fe, 0x55fcba0f));
		__LOLIX_INTERFACE(load		, LOLIX_RETNV,	(loli::file*, lolix::toy::time_span buffer_time));
		__LOLIX_INTERFACE(save		, LOLIX_RETNV,	(loli::file*)const);
	};

	//	通过 kanon::query_itf 来取得
	class	LOLIX_NO_VTABLE	kscore
		: public itf
	{
	public:
		LOLIX_DECLARE_ITF(lolix::pretty::kanon::ksource, lolix::itf, (0x13c7ea74, 0xf5db4be8, 0xba09cd94, 0x56163a32));
		LOLIX_INTERFACE(supports,		LOLIX_RETNV, (LOLIX_ITF_ID* out_id, size_type* io_size)const);	//	io_size : in=> out_id buffer cnt, out => need_size
		LOLIX_INTERFACE(setbuffer,	LOLIX_RETNV, (const kbuffer*));//(const ksource_info*, LOLIX_ITF_ID const* in_buff_type));
	};


	//	通过 kanon::query_itf 来取得
	class	LOLIX_NO_VTABLE	player
		: public itf
	{
	public:
		LOLIX_DECLARE_ITF(lolix::pretty::kanon::player, lolix::itf, (0xbae9ed9c, 0xc7944267, 0xb5174ec3, 0x8a153341));
		__LOLIX_INTERFACE(listen,		LOLIX_RETNV, (void));
		__LOLIX_INTERFACE(set_dancer,	LOLIX_RETNV, (sola::dancer* const, sola::dancer** old));	//	if old is null, than invoke release at old_ptr, else for do nothing.
		__LOLIX_INTERFACE(gain,			LOLIX_RETNV, (float));
		__LOLIX_INTERFACE(push_back,	LOLIX_RETNV, (kscore*));
		__LOLIX_INTERFACE(push_back,	LOLIX_RETNV, (kscore** bg, kscore** ed));
		__LOLIX_INTERFACE(play,			LOLIX_RETNV, (float));	//	for play speed, zero is pause
		__LOLIX_INTERFACE(rewind,		LOLIX_RETNV, (void));
	};

	//===========================================================================
	//	枚举当前设备
	//---------------------------------------------------------------------------
	//	buff_num		[ o]	得到当前设备的内容
	//	dev_cnt			[io]	i: 缓冲区的数量, o: 需要缓冲区的数量
	//	dev_name_len	[io]	i: 输入缓冲区的平均长度, o: 需要缓冲区的长度(带0结尾)
	//===========================================================================
	LOLIX_INTERFACE(enum_dev,			LOLIX_RETNV, (char** buff_num, size_type* io_dev_cnt, size_type* io_dev_name_len)const);
	LOLIX_INTERFACE(usage_devname,	LOLIX_RETNV, (const char* name));
	LOLIX_INTERFACE(make_active	,	LOLIX_RETNV, (bool trun_to_active));

	LOLIX_INTERFACE(query_listener,	LOLIX_RETNV, (player** out_listen));

	LOLIX_INTERFACE(attach,			LOLIX_RETNV, (kbuffer::factory_type* in_buffer, LOLIX_ITF_ID const* spt_fmt, size_type fmt_cnt));
};


namespace lolix{namespace pretty{
	__LOLIX_DEFINE_ID_INTERFACE(kbuf_type_wave,	(0x5ac03ba8, 0x357c459f, 0x8585a31d, 0x54ef3b4f));
	__LOLIX_DEFINE_ID_INTERFACE(kstr_type_wave,	(0xc30e5506, 0x52ac705d, 0x70a46dc7, 0x2ff3cbf1));
	__LOLIX_DEFINE_ID_INTERFACE(kbuf_type_ogg,	(0x55c0ea41, 0x0fd14a31, 0xa44abf71, 0xbd0ad6bb));
}};


SYS_REGIST_TYPE(lolix::pretty::kanon);
SYS_REGIST_TYPE(lolix::pretty::kanon::factory_type);
SYS_REGIST_TYPE(lolix::pretty::kanon::kbuffer);
SYS_REGIST_TYPE(lolix::pretty::kanon::kscore);
SYS_REGIST_TYPE(lolix::pretty::kanon::ksource);
SYS_REGIST_TYPE(lolix::pretty::kanon::ksource::factory_type);
SYS_REGIST_TYPE(lolix::pretty::kanon::ksource_info);
SYS_REGIST_TYPE(lolix::pretty::kanon::kstream);
SYS_REGIST_TYPE(lolix::pretty::kanon::player);
SYS_REGIST_TYPE(lolix::pretty::kbuf_type_ogg);
SYS_REGIST_TYPE(lolix::pretty::kbuf_type_wave);

//--------------------------------------------------------------------------
//==============================================================================
#endif	//	!defined(__LOLIX__PRETTY__KANON__NICK__K_IN_G__)
